/***************************************************************************
 *   Copyright (C) 2009 by Bernhard Neuhofer   *
 *   mail@bneu.at   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#ifndef VECTORBUFFER_H
#define VECTORBUFFER_H

#include "messageContainer.h"
#include "message.h"
#include <ostream>
#include <vector>

/**
* @brief A Message Container based on STL <code>vector</code>
*/
class VectorBuffer:public MessageContainer
{
	public:

		/**
		 * Constructs an empty <code>VectorBuffer</code>
		 */
		VectorBuffer() {_vector.reserve ( 50 );}

		/**
		 * @see MessageContainer#first
		 * @return
		 */
		virtual Message* first();

		/**
		 * @see MessageContainer#last
		 * @return
		 */
		virtual Message* last();

		/**
		 * @see MessageContainer#next
		 * @return
		 */
		virtual Message* next ( Message* message );

		/**
		 * @see MessageContainer#prev
		 * @return
		 */
		virtual Message* prev ( Message* message );

		/**
		 * @see MessageContainer#isEmpty
		 * @return
		 */
		virtual bool isEmpty();

		/**
		 * @see MessageContainer#size
		 * @return
		 */
		virtual unsigned int size();

		/**
		 * @see MessageContainer#contains
		 * @return
		 */
		virtual bool contains ( Message* message );

		/**
		 * @see MessageContainer#insert
		 * @param message
		 */
		virtual void insert ( Message* message );

		/**
		 * @see MessageContainer#remove
		 * @param message
		 */
		virtual void remove ( Message* message );

		/**
		 * Prints the messages in the Vector. Used for debugging only
		 * @param out
		 * @param x
		 * @return
		 */
		friend ostream& operator<< ( ostream& out, VectorBuffer vb );

		virtual void clear();

	protected:
		/**
		* Vector which holds the messages
		*/
		vector<Message*> _vector; //=new vector<Message>();
};



#endif
